package com.tools.compass;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class CompassView extends ImageView {

	private Drawable compass;
	private float mDirection = 0.0F;

	public CompassView(Context paramContext) {
		super(paramContext);
	}

	public CompassView(Context paramContext, AttributeSet paramAttributeSet) {
		super(paramContext, paramAttributeSet);
	}

	public CompassView(Context paramContext, AttributeSet paramAttributeSet,
			int paramInt) {
		super(paramContext, paramAttributeSet, paramInt);
	}

	protected void onDraw(Canvas paramCanvas) {
		this.compass = getDrawable();
		Drawable localDrawable2 = this.compass;
		int i = getWidth();
		int j = getHeight();
		localDrawable2.setBounds(0, 0, i, j);
		paramCanvas.save();
		float f1 = this.mDirection;
		float f2 = getWidth() / 2;
		float f3 = getHeight() / 2;
		paramCanvas.rotate(f1, f2, f3);
		this.compass.draw(paramCanvas);
		paramCanvas.restore();
	}

	public void updateDirection(float paramFloat) {
		this.mDirection = paramFloat;
		invalidate();
	}

}
